<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>我的收藏 - 金车二手车</title>
	<meta content="金车二手车" name="keywords" />
	<meta content="金车二手车" name="description" />
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="iconfont/iconfont.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="stylesheet" type="text/css" href="css/style3.css">
	<!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	<script type="text/javascript" src="script/jquery.js"></script>
	<script type="text/javascript" src="script/bootstrap.min.js"></script>
	<script type="text/javascript" src="script/layer.js"></script>

	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="stylesheet" type="text/css" href="css/scroll.css">

	<link rel="stylesheet" href="css/news.css" />
	<link rel="stylesheet" href="css/style3.css" />
	<link rel="stylesheet" href="css/style4.css" />
	<link rel="stylesheet" type="text/css" href="css/style1.css">
	<script type="text/javascript" src="script/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="script/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/scroll.js"></script>
	<!--<link rel="stylesheet" href="css/mui.min.css">-->
	<link rel="stylesheet" type="text/css" href="css/feedback-page.css" />



	<link rel="stylesheet" href="css/demo.css" />

	<script language="JavaScript">
		$(function () {
			$('.carnum').delay(2000).hide(0);
			$('.nextpage').click(function () {
				var nextpage = parseInt($("input[name=nextpage]").val());
				var page = parseInt($("input[name=page]").val());
				$.get("" + nextpage,
					function (data, textStatus) {
						if (data != '') {
							$("#listcar").append(data);
							$("input[name=page]").val(1);
						} else {
							$("#pagestatus").show().html("加载完毕，已没有更多预约信息");
							$(".nextpage").hide();
						}
					}
				);
				$("input[name=nextpage]").val(nextpage + 1);
			});
		})
	</script>
</head>

<body>
	<div class="black_overlay"></div>
	<!--内容-->
	<header class="mo-header">
		<div class="mo-header-left">
			<a href="#"> 我的发布</a>
			<!--<a href="#"> 会员中心 </a> <i class="iconfont">&#xe61d;</i>
				<a href="#"> 我的预约 </a>-->
		</div>
	</header>
	<div class="myreport">
		<span class="car" onclick="car()">轿车</span>
		<span class="truck" onclick="truck()">货车</span>
	</div>
	<div>
		<!--<div class="listcar">
		    <div class="carimg"> 
		    	<a href="#" target="_blank"><img data-original="img/carimg.jpg" width="300" height="230" class="img-responsive lazy"/></a>
		    </div>
		    <div class="carinfo">
		          <h4><a href="#" target="_blank">奥迪A4L 2013款 奥迪A4L 30 TFSI 自动 舒适型</a> </h4>
		          <p class="caritem"> 上牌 / 20.00万公里</p>
		          <span class="carprice">29.10万元</span>
		          <span class="deal">成交</span>
		          <span class="refresh">刷新</span>
		          <span class="modify">修改</span>
		          <span class="delete">删除</span>
		    </div>
	    </div>-->
	</div>
	<div id="listcar"></div>
	<div id="pagestatus" style="display:none;"></div>
	<!--<a href="javascript:;" id="returntop"></a>-->
	<script type="text/javascript" src="script/jquery.lazyload.js"></script>
	<!--<script src="js/mui.min.js"></script>-->
	<script src="js/mui.js"></script>

	<script src='js/feedback.js'></script>
	<script src="js/app.js"></script>
	<script>
		mui.back = function () {
			var btn = ["确定", "取消"];
			mui.confirm('确认关闭当前应用？', '提示', btn, function (e) {
				if (e.index == 0) {
					plus.runtime.quit();
				}
			});
		}
	</script>
	<script type="text/javascript" charset="utf-8">
		$(function () {
			$("img.lazy").lazyload({
				effect: "fadeIn"
			});
			/*$('#returntop').click(function() {
				$('html,body').animate({
					scrollTop: '0px'
				}, 1000);
				return false;
			});*/
		});
	</script>

	<script>
		var telephone = window.localStorage.getItem("telephone");
		window.onload = function () {
			car();
		}

		function car() {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/selectMyCarReport",
				async: false,
				type: "post",
				dataType: "json",
				data: {
					"telephone": telephone
				},
				success: function (data) {
					carsuccess(data);
				},
				error: function (data) {}
			});
		}

		function truck() {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/selectMyTruckReport",
				async: false,
				type: "post",
				dataType: "json",
				data: {
					"telephone": telephone
				},
				success: function (data) {
					trucksuccess(data);
				},
				error: function (data) {
					window.alert("错误");
					//window.alert(data);
				}
			});
		}

		function modifyCar(id) {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/selectCarInfo",
				async: false,
				type: "post",
				dataType: "json",
				//data: {"id":$("input[name='id']").val()},
				data: {
					"id": id
				},
				success: function (data) {
					window.location.href = 'report.html';
					$("#cartype").html(data[0].cartype);
				},
				error: function (data) {
					window.alert("错误");
					//window.alert(data);
				}
			});
		}

		function deleteCar(id) {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/deleteCar",
				async: false,
				type: "post",
				//dataType: "json",
				//data: {"id":$("input[name='id']").val()},
				data: {
					"id": id
				},
				success: function (data) {
					if (data == 'success') {
						window.alert("删除成功");
						//window.location.reload();
						location.reload(true);
					}
				},
				error: function (data) {
					window.alert("删除失败");
					//window.alert(data);
				}
			});
		}

		function deleteTruck(id) {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/deleteTruck",
				async: false,
				type: "post",
				//dataType: "json",
				//data: {"id":$("input[name='id']").val()},
				data: {
					"id": id
				},
				success: function (data) {
					alert("删除成功");
					if (data == 'success') {
						$.ajax({
							url: servicePath + "sechandcar/app/sys/selectMyTruckReport",
							async: false,
							type: "post",
							dataType: "json",
							data: {
								"telephone": telephone
							},
							success: function (data) {
								//window.alert(data.);
								trucksuccess(data);
							},
							error: function (data) {
								window.alert("错误");
								//window.alert(data);
							}
						});
					}
				},
				error: function (data) {
					window.alert("删除失败");
					//window.alert(data);
				}
			});
		}

		function carDeal(id) {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/carDeal",
				async: false,
				type: "post",
				//dataType: "json",
				//data: {"id":$("input[name='id']").val()},
				data: {
					"id": id
				},
				success: function (data) {
					if (data == 'success') {
						alert("设置成功");
						$.ajax({
							url: servicePath + "sechandcar/app/sys/selectMyCarReport",
							async: false,
							type: "post",
							dataType: "json",
							data: {
								"telephone": telephone
							},
							success: function (data) {
								carsuccess(data);
							},
							error: function (data) {
								window.alert("错误");
								//window.alert(data);
							}
						});
					}
				},
				error: function (data) {
					window.alert("成交失败");
					//window.alert(data);
				}
			});
		}

		function carRefresh(id) {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/carRefresh",
				async: false,
				type: "post",
				//dataType: "json",
				//data: {"id":$("input[name='id']").val()},
				data: {
					"id": id
				},
				success: function (data) {
					if (data == 'success') {
						alert("刷新成功")
						$.ajax({
							url: servicePath + "sechandcar/app/sys/selectMyCarReport",
							async: false,
							type: "post",
							dataType: "json",
							data: {
								"telephone": telephone
							},
							success: function (data) {
								//window.alert(data.length);
								carsuccess(data);
							},
							error: function (data) {
								window.alert("错误");
								//window.alert(data);
							}
						});
					}
				},
				error: function (data) {
					window.alert("刷新失败");
					//window.alert(data);
				}
			});
		}

		function truckDeal(id) {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/truckDeal",
				async: false,
				type: "post",
				//dataType: "json",
				//data: {"id":$("input[name='id']").val()},
				data: {
					"id": id
				},
				success: function (data) {
					alert("设置成功");
					if (data == 'success') {
						$.ajax({
							url: servicePath + "sechandcar/app/sys/selectMyTruckReport",
							async: false,
							type: "post",
							dataType: "json",
							data: {
								"telephone": telephone
							},
							success: function (data) {
								//window.alert(data.length);
								trucksuccess(data);
							},
							error: function (data) {
								window.alert("错误");
								//window.alert(data);  
							}
						});
					}
				},
				error: function (data) {
					window.alert("成交失败");
					//window.alert(data);
				}
			});
		}

		function truckRefresh(id) {
			$.ajax({
				url: servicePath + "sechandcar/app/sys/truckRefresh",
				async: false,
				type: "post",
				//dataType: "json",
				//data: {"id":$("input[name='id']").val()},
				data: {
					"id": id
				},
				success: function (data) {
					if (data == 'success') {
						alert("刷新成功");
						$.ajax({
							url: servicePath + "sechandcar/app/sys/selectMyTruckReport",
							async: false,
							type: "post",
							dataType: "json",
							data: {
								"telephone": telephone
							},
							success: function (data) {
								//window.alert(data.length);
								//window.alert("货车刷新成功");
								trucksuccess(data);
							},
							error: function (data) {
								window.alert("错误");
								//window.alert(data);     
							}
						});
					}
				},
				error: function (data) {
					window.alert("删除失败");
					//window.alert(data);
				}
			});
		}

		function carsuccess(data) {
			$('#listcar').empty();
			for (var i = 0; i < data.length; i++) {
				var s = '<div class="listcar">';
				s += '<div class="carimg"><img src="' + servicePath + '' + data[i].photo1 +
					'"  class="img-responsive lazy" /> </div>' +
					'<div class="carinfo">' +
					'<h4>' + data[i].brandmodel + '</h4>' +
					'<p class="caritem">' + data[i].registrationdate + ' 上牌/ ' + data[i].mileage + '万公里</p>' +
					'<span class="carprice">￥' + data[i].wholesaleprice + '万元</span>' +
					'<span class="deal" onclick="carDeal(' + data[i].id + ');return false;">成交</span>' +
					'<span class="refresh" onclick="carRefresh(' + data[i].id + ');return false;">刷新</span>' +
					'<span class="modify" onclick="modifyCar(' + data[i].id + ');return false;">修改</span>' +
					'<span class="delete" onclick="deleteCar(' + data[i].id + ');return false;">删除</span>' +
					'</div>' +
					'</a>' +
					'</div>';
				$('#listcar').append(s);
				//$("input[name='id']").val(data[i].id);
			}
		}

		function trucksuccess(data) {
			$('#listcar').empty();
			for (var i = 0; i < data.length; i++) {
				var s = '<div class="listcar">';
				s += '<div class="carimg"><img src="' + servicePath + '' + data[i].photo1 +
					'" class="img-responsive lazy" /> </div>' +
					'<div class="carinfo">' +
					'<h4>' + data[i].brandmodel + '</h4>' +
					'<p class="caritem">' + data[i].registrationdate + ' 上牌/ ' + data[i].mileage + '万公里</p>' +
					'<span class="carprice">￥' + data[i].wholesaleprice + '万元</span>' +
					'<span class="deal" onclick="truckDeal(' + data[i].id + ');return false;">成交</span>' +
					'<span class="refresh" onclick="truckRefresh(' + data[i].id + ');return false;">刷新</span>' +
					'<span class="modify" onclick="modifyTruck(' + data[i].id + ');return false;">修改</span>' +
					'<span class="delete" onclick="deleteTruck(' + data[i].id + ');return false;">删除</span>' +
					'</div>' +
					'</a>' +
					'</div>';
				$('#listcar').append(s);
			}
		}

		function modifyCar(id) {
			mui.openWindow({
				id: 'modifyCar',
				url: 'modifyCar.html',
				createNew: true,
				waiting: {
					autoShow: true,
					title: '正在加载...',
				},
				extras: {
					ids: id
				}
			});

		}

		function modifyTruck(id) {
			//				window.location.href = "report.html?id=" + id + "&type=truck";
			mui.openWindow({
				id: 'modifyTruck',
				url: 'modifyTruck.html',
				createNew: true,
				waiting: {
					autoShow: true,
					title: '正在加载...',
				},
				extras: {
					ids: id
				}
			});
		}
	</script>

</body>

</html>